<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>generator</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui@2.0.5/lib/theme-chalk/index.css">
    <script src="https://cdn.bootcss.com/vue/2.6.5/vue.common.dev.js"></script>
    <script src="http://cdn.bootcss.com/vue-resource/1.3.4/vue-resource.js"></script>
    <script src="https://unpkg.com/element-ui@2.0.5/lib/index.js"></script>
    <style>
        #top {
            background:#20A0FF;
            padding:5px;
            overflow:hidden
        }
    </style>

</head>
<body>
<div id="generator">
   <div width="50%">
       <el-form>
           <el-form-item label="*表名" label-width="120px" style="width:50%">
               <el-input v-model="tableName" placeholder="请输入表名"></el-input>
           </el-form-item>
           <el-form-item label="模块名" label-width="120px" style="width:50%">
               <el-input v-model="moduleName" placeholder="请输入模块名"></el-input>
           </el-form-item>
           <el-form-item label="*创建人" label-width="120px" style="width:50%">
               <el-input v-model="createName" placeholder="请输入创建人"></el-input>
           </el-form-item>

           <el-form-item label="" label-width="120px" style="width:50%">
               <el-button type="primary" @click="save">提交</el-button>
           </el-form-item>
       </el-form>
   </div>
</div>
<script>
    const baseUrl = "http://localhost:8080/";
    var vue = new Vue({
        el:"#generator",
        data: {
            saveUri:'/sysGeneratorRecord/generate',
            moduleName:'',
            tableName: '',
            createName:'',
            targetDirectory:'F:/generate/'
        },
        methods: {
            //从服务器读取数据
            loadData: function(){

            },
            //单行删除
            save: function() {
                var than = this;
                if (!this.tableName || !this.tableName.trim()){
                    than.$message({message:'表名不能为空', type: 'warning'});
                    return
                }
                if (!this.createName || !this.createName.trim()){
                    than.$message({message:'创建人不能为空', type: 'warning'});
                    return
                }
                if (this.createName){
                    this.createName = this.createName.trim()
                }

                var postDate={
                    moduleName: this.moduleName.trim(),
                    tableName: this.tableName.trim(),
                    createName:this.createName.trim(),
                    targetDirectory:this.targetDirectory.trim()
                }

                var than = this;
                this.$http.post(baseUrl+this.saveUri,postDate).then(function(res){
                    if (res.data.code == 200){
                        than.$message({message:'操作成功', type: 'success'});
                    }else{
                        than.$message({message: res.data.message, type: 'warning'});
                    }
                },function(){
                    than.$message({message: '请求失败', type: 'error'});
                });
            },
        },



    });
</script>

</body>
</html>